# Top level makefile fragment for GNU Objective-C++.
#   Copyright (C) 1994, 1995 Free Software Foundation, Inc.

#This file is part of GNU CC.

#GNU CC is free software; you can redistribute it and/or modify
#it under the terms of the GNU General Public License as published by
#the Free Software Foundation; either version 2, or (at your option)
#any later version.

#GNU CC is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#GNU General Public License for more details.

#You should have received a copy of the GNU General Public License
#along with GNU CC; see the file COPYING.  If not, write to
#the Free Software Foundation, 59 Temple Place - Suite 330,
#Boston, MA 02111-1307, USA.

# This file provides the language dependent support in the main Makefile.
# Each language makefile fragment must provide the following targets:
#
# foo.all.build, foo.all.cross, foo.start.encap, foo.rest.encap,
# foo.info, foo.dvi,
# foo.install-normal, foo.install-common, foo.install-info, foo.install-man,
# foo.uninstall, foo.distdir,
# foo.mostlyclean, foo.clean, foo.distclean, foo.extraclean,
# foo.maintainer-clean, foo.stage1, foo.stage2, foo.stage3, foo.stage4
#
# where `foo' is the name of the language.
#
# It should also provide rules for:
#
# - making any compiler driver (eg: g++)
# - the compiler proper (eg: cc1objplus)
# - define the names for selecting the language in LANGUAGES.

# Extra flags to pass to recursive makes.
OBJCXX_FLAGS_TO_PASS = \
	"CXX_FOR_BUILD=$(CXX_FOR_BUILD)" \
	"OBJCXXFLAGS=$(OBJCXXFLAGS)" \
	"CXX_FOR_TARGET=$(CXX_FOR_TARGET)"

# Define the names for selecting c++ in LANGUAGES.
# Note that it would be nice to move the dependency on g++
# into the C++ rule, but that needs a little bit of work
# to do the right thing within all.cross.
OBJC++ objc++ OBJECTIVE-C++ objective-c++: cc1objplus$(exeext)

# Tell GNU make to ignore these if they exist.
.PHONY: OBJC++ objc++ OBJECTIVE-C++ objective-c++

OBJCCXX_SRCS = $(srcdir)/obcp/call.c $(srcdir)/obcp/decl2.c \
 $(srcdir)/obcp/except.c $(srcdir)/obcp/input.c $(srcdir)/obcp/pt.c \
 $(srcdir)/obcp/spew.c $(srcdir)/obcp/xref.c $(srcdir)/obcp/class.c \
 $(srcdir)/obcp/edsel.c $(srcdir)/obcp/expr.c $(srcdir)/obcp/lex.c \
 $(srcdir)/obcp/ptree.c $(srcdir)/obcp/tree.c $(srcdir)/obcp/cvt.c \
 $(srcdir)/obcp/errfn.c $(srcdir)/obcp/gc.c $(srcdir)/obcp/method.c \
 $(srcdir)/obcp/search.c $(srcdir)/obcp/typeck.c $(srcdir)/obcp/decl.c \
 $(srcdir)/obcp/error.c $(srcdir)/obcp/init.c $(srcdir)/obcp/parse.in \
 $(srcdir)/obcp/sig.c $(srcdir)/obcp/typeck2.c $(srcdir)/obcp/repo.c

cc1objplus$(exeext): $(P) $(OBJCCXX_SRCS) $(LIBDEPS) stamp-objlist c-common.o c-pragma.o
	cd obcp; $(MAKE) $(FLAGS_TO_PASS) $(CXX_FLAGS_TO_PASS) ../cc1objplus

# Build hooks:

objective-c++.all.build:
objective-c++.all.cross:
objective-c++.start.encap:
objective-c++.rest.encap:

objective-c++.info:
objective-c++.dvi:

# Install hooks:
# cc1objplus is installed elsewhere as part of $(COMPILERS).

# Nothing to do here.
objective-c++.install-normal:

# Install the driver program as $(target)-g++
# and also as either g++ (if native) or $(tooldir)/bin/g++.
objective-c++.install-common:
	-if [ -f cc1objplus$(exeext) ] ; then \
	  if [ -f g++-cross$(exeext) ] ; then \
	    rm -f $(bindir)/$(GXX_CROSS_NAME)$(exeext); \
	    $(INSTALL_PROGRAM) g++-cross$(exeext) $(bindir)/$(GXX_CROSS_NAME)$(exeext); \
	    chmod a+x $(bindir)/$(GXX_CROSS_NAME)$(exeext); \
	    rm -f $(bindir)/$(CXX_CROSS_NAME)$(exeext); \
	    ln $(bindir)/$(GXX_CROSS_NAME)$(exeext) $(bindir)/$(CXX_CROSS_NAME)$(exeext) \
	      > $(NULL) 2>&1 \
	      || cp $(bindir)/$(GXX_CROSS_NAME)$(exeext) $(bindir)/$(CXX_CROSS_NAME)$(exeext) ; \
	  else \
	    rm -f $(bindir)/$(GXX_INSTALL_NAME)$(exeext); \
	    $(INSTALL_PROGRAM) g++$(exeext) $(bindir)/$(GXX_INSTALL_NAME)$(exeext); \
	    chmod a+x $(bindir)/$(GXX_INSTALL_NAME)$(exeext); \
	    rm -f $(bindir)/$(CXX_INSTALL_NAME)$(exeext); \
	    ln $(bindir)/$(GXX_INSTALL_NAME)$(exeext) $(bindir)/$(CXX_INSTALL_NAME)$(exeext) \
	      > $(NULL) 2>&1 \
	      || cp $(bindir)/$(GXX_INSTALL_NAME)$(exeext) $(bindir)/$(CXX_INSTALL_NAME)$(exeext) ; \
	  fi ; \
	fi

objective-c++.install-info:

objective-c++.install-man:

objective-c++.uninstall:

# Clean hooks:
# A lot of the ancillary files are deleted by the main makefile.
# We just have to delete files specific to us.

objective-c++.mostlyclean:
	-rm -f obcp/*$(objext)
objective-c++.clean:
objective-c++.distclean:
	-rm -f obcp/config.status obcp/Makefile
	-rm -f obcp/parse.output
objective-c++.extraclean:
objective-c++.maintainer-clean:
	-rm -f obcp/parse.c obcp/parse.h

# Stage hooks:
# The main makefile has already created stage?/obcp.

objective-c++.stage1:
	-mv obcp/*$(objext) stage1/obcp
objective-c++.stage2:
	-mv obcp/*$(objext) stage2/obcp
objective-c++.stage3:
	-mv obcp/*$(objext) stage3/obcp
objective-c++.stage4:
	-mv obcp/*$(objext) stage4/obcp

# Maintenance hooks:

# This target creates the files that can be rebuilt, but go in the
# distribution anyway.  It then copies the files to the distdir directory.
objective-c++.distdir:
	mkdir tmp/obcp
	cd obcp ; \
	$(MAKE) $(FLAGS_TO_PASS) $(OBJCXX_FLAGS_TO_PASS) parse.c hash.h
	cd obcp; \
	for file in *[0-9a-zA-Z+]; do \
	  ln $$file ../tmp/obcp >$(NULL) 2>&1 || cp $$file ../tmp/obcp; \
	done
